package cn.shuangliang.contract.test;

import cn.shuangliang.contract.dao.ContractMapper;
import cn.shuangliang.contract.model.Contract;
import cn.shuangliang.contract.model.Product;
import cn.shuangliang.contract.service.AdminService;
import cn.shuangliang.contract.service.ProductService;
import cn.shuangliang.contract.vo.Page;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class TEst {
    public static void main(String[] args)
    {
        ApplicationContext ac=new ClassPathXmlApplicationContext("spring-mybatis.xml");
//        SqlSessionTemplate sqlTemplate = ac.getBean("sqlTemplate", SqlSessionTemplate.class);
//        ContractMapper mapper = sqlTemplate.getMapper(ContractMapper.class);
//        List<Contract> list = mapper.search(1, 10, null, null, null, null);
//        list.forEach(System.out::println);

//        AdminService bean = ac.getBean(AdminService.class);
//        System.out.println(bean.login("admin","123456"));
        ProductService productService=ac.getBean(ProductService.class);
        Page<Product> search = productService.search(1, 10, null, null);
        search.getData().forEach(System.out::println);
    }
}
